def func(arr, x):
    l = 0
    r = len(arr) - 1
    while l < r:
        n = (l + r) // 2
        i = arr[n]
        if i > x:
            r = n
        elif i < x:
            l = n + 1
        else:
            return f'元素{x}在列表中下标为{n}的位置'
    return f'元素{x}不在列表中'


def func1(arr):
    for i in range(1, len(arr)):
        for j in range(len(arr) - i):
            if arr[j] > arr[j + 1]:
                arr[j + 1], arr[j] = arr[j], arr[j + 1]


if __name__ == '__main__':
    arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 15, 16, 18, 20, 23, 25, 28, 31, 32, 35, 40, 41]
    x = 16
    res = func(arr, x)
    print(res)